package com.siwei.mes.common.util;

import cn.hutool.core.date.DateTime;
import lombok.extern.slf4j.Slf4j;
import net.sourceforge.pinyin4j.PinyinHelper;
import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
import net.sourceforge.pinyin4j.format.HanyuPinyinVCharType;
import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;

import java.text.SimpleDateFormat;
import java.util.Date;


@Slf4j
public class UploadFlagUtils {


    public static void main(String[] args) {

        String value = "10" + "±" + "20";
        String mm = value.replace("mm", "");

        System.out.println(mm);
    }


    public static String CtoGB_Num(String tempstr, String Type, Date TestDate,String value)
    {
        // 将传入的字符串、类型和日期组合在一起
        if(value != null && !"".equals(value)){
            tempstr = tempstr + Type + value;
        }else{
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            String strDate = sdf.format(TestDate);
            tempstr = tempstr + Type + strDate;
        }


        // 获取组合后字符串的长度
        int num = tempstr.length();
        // 初始化一个变量并赋值为 1
        int num2 = 1;
        // 初始化一个字符串变量
        String text = "";
        int millisecond;

        // 一个无限循环，直到满足条件退出
        while (true)
        {
            // 定义两个临时变量
            int num3 = num2;
            int num4 = num;
            // 如果第二个变量大于第一个变量，退出循环
            if (num3 > num4)
            {
                break;
            }
            // 获取字符串的第一个字符
            String chr = tempstr.substring(0,1);
            // 去掉字符串的第一个字符
            tempstr = tempstr.substring(1);
            // 将处理后的字符添加到结果字符串中
            text += ChangeChr(chr);
            // 第二个变量自增
            num2++;
        }
        // 获取当前时间的毫秒数
        millisecond = Integer.parseInt(String.valueOf(System.currentTimeMillis() % 1000));


        // 再次初始化一个字符串变量
        String text2 = "";
        // 根据毫秒数的范围赋值给 text2
        if (millisecond >= 0 && millisecond <= 100)
        {
            text2 = "0";
        }
        if (millisecond > 100 && millisecond <= 200)
        {
            text2 = "1";
        }
        if (millisecond > 200 && millisecond <= 300)
        {
            text2 = "2";
        }
        if (millisecond > 300 && millisecond <= 400)
        {
            text2 = "3";
        }
        if (millisecond > 400 && millisecond <= 500)
        {
            text2 = "4";
        }
        if (millisecond > 500 && millisecond <= 600)
        {
            text2 = "5";
        }
        if (millisecond > 600 && millisecond <= 700)
        {
            text2 = "6";
        }
        if (millisecond > 700 && millisecond <= 800)
        {
            text2 = "7";
        }
        if (millisecond > 800 && millisecond <= 900)
        {
            text2 = "8";
        }
        if (millisecond > 900 && millisecond <= 999)
        {
            text2 = "9";
        }
        // 再次初始化一个字符串变量
        String text3 = "";
        // 根据 text2 的值进行不同的处理
        switch (text2)
        {
            case "0":
                // 重新获取当前时间的毫秒数
                millisecond = Integer.parseInt(String.valueOf(System.currentTimeMillis() % 1000));
                if (millisecond >= 0 && millisecond <= 300)
                {
                    text3 = "";
                }
                if (millisecond > 300 && millisecond <= 600)
                {
                    text3 = "";
                }
                if (millisecond > 500 && millisecond <= 999)
                {
                    text3 = "";
                }
                break;
            case "1":
                millisecond = Integer.parseInt(String.valueOf(System.currentTimeMillis() % 1000));
                if (millisecond >= 0 && millisecond <= 300)
                {
                    text3 = "@";
                }
                if (millisecond > 300 && millisecond <= 600)
                {
                    text3 = "#";
                }
                if (millisecond > 500 && millisecond <= 999)
                {
                    text3 = "$";
                }
                break;
            case "2":
                millisecond = Integer.parseInt(String.valueOf(System.currentTimeMillis() % 1000));
                if (millisecond >= 0 && millisecond <= 300)
                {
                    text3 = "@#";
                }
                if (millisecond > 300 && millisecond <= 600)
                {
                    text3 = "#@";
                }
                if (millisecond > 500 && millisecond <= 999)
                {
                    text3 = "$#";
                }
                break;
            case "3":
                millisecond = Integer.parseInt(String.valueOf(System.currentTimeMillis() % 1000));
                if (millisecond >= 0 && millisecond <= 300)
                {
                    text3 = "@#$";
                }
                if (millisecond > 300 && millisecond <= 600)
                {
                    text3 = "#@$";
                }
                if (millisecond > 500 && millisecond <= 999)
                {
                    text3 = "$#%";
                }
                break;
            case "4":
                millisecond = Integer.parseInt(String.valueOf(System.currentTimeMillis() % 1000));
                if (millisecond >= 0 && millisecond <= 300)
                {
                    text3 = "*&^%";
                }
                if (millisecond > 300 && millisecond <= 600)
                {
                    text3 = "@#$*";
                }
                if (millisecond > 500 && millisecond <= 999)
                {
                    text3 = "%$^&";
                }
                break;
            case "5":
                millisecond = Integer.parseInt(String.valueOf(System.currentTimeMillis() % 1000));
                if (millisecond >= 0 && millisecond <= 300)
                {
                    text3 = "!@#$%";
                }
                if (millisecond > 300 && millisecond <= 600)
                {
                    text3 = "#!*&^";
                }
                if (millisecond > 500 && millisecond <= 999)
                {
                    text3 = "%$@!&";
                }
                break;
            case "6":
                millisecond = Integer.parseInt(String.valueOf(System.currentTimeMillis() % 1000));
                if (millisecond >= 0 && millisecond <= 300)
                {
                    text3 = "%$#@!*";
                }
                if (millisecond > 300 && millisecond <= 600)
                {
                    text3 = "@!#$%^";
                }
                if (millisecond > 500 && millisecond <= 999)
                {
                    text3 = "*&^%$@";
                }
                break;
            case "7":
                millisecond = Integer.parseInt(String.valueOf(System.currentTimeMillis() % 1000));
                if (millisecond >= 0 && millisecond <= 300)
                {
                    text3 = "&*^%@#$";
                }
                if (millisecond > 300 && millisecond <= 600)
                {
                    text3 = "*^&%#@!";
                }
                if (millisecond > 500 && millisecond <= 999)
                {
                    text3 = "#@!$%^*";
                }
                break;
            case "8":
                millisecond = Integer.parseInt(String.valueOf(System.currentTimeMillis() % 1000));
                if (millisecond >= 0 && millisecond <= 300)
                {
                    text3 = "&*^%$#@!";
                }
                if (millisecond > 300 && millisecond <= 600)
                {
                    text3 = "^%&*$@!#";
                }
                if (millisecond > 500 && millisecond <= 999)
                {
                    text3 = "%^*&@#$!";
                }
                break;
            case "9":
                millisecond = Integer.parseInt(String.valueOf(System.currentTimeMillis() % 1000));
                if (millisecond >= 0 && millisecond <= 300)
                {
                    text3 = "!#@$@^&%*";
                }
                if (millisecond > 300 && millisecond <= 600)
                {
                    text3 = "&^*%$%#@!";
                }
                if (millisecond > 500 && millisecond <= 999)
                {
                    text3 = "#!@$@%^&*";
                }
                break;
        }
        // 返回处理后的结果字符串
        return ChangeChr(text2) + text3 + text;
    }


    public static String ChangeChr(String Chr)
    {
        int num = 0;
        String result = "";
        switch (Chr)
        {
            case "0":
                num = Integer.parseInt(String.valueOf(System.currentTimeMillis() % 1000));
                if (num >= 0 && num <= 300)
                {
                    result = "@#$";
                }
                if (num > 300 && num <= 600)
                {
                    result = "#$@";
                }
                if (num > 500 && num <= 999)
                {
                    result = "$#@";
                }
                break;
            case "1":
                num = Integer.parseInt(String.valueOf(System.currentTimeMillis() % 1000));
                if (num >= 0 && num <= 300)
                {
                    result = "%^&";
                }
                if (num > 300 && num <= 600)
                {
                    result = "^%&";
                }
                if (num > 600 && num <= 999)
                {
                    result = "&%^";
                }
                break;
            case "2":
                num = Integer.parseInt(String.valueOf(System.currentTimeMillis() % 1000));
                if (num >= 0 && num <= 300)
                {
                    result = "*!@";
                }
                if (num > 300 && num <= 600)
                {
                    result = "@!*";
                }
                if (num > 500 && num <= 999)
                {
                    result = "!*@";
                }
                break;
            case "3":
                num = Integer.parseInt(String.valueOf(System.currentTimeMillis() % 1000));
                if (num >= 0 && num <= 300)
                {
                    result = "#*^";
                }
                if (num > 300 && num <= 600)
                {
                    result = "^*#";
                }
                if (num > 600 && num <= 999)
                {
                    result = "*#^";
                }
                break;
            case "4":
                num = Integer.parseInt(String.valueOf(System.currentTimeMillis() % 1000));
                if (num >= 0 && num <= 300)
                {
                    result = "$@%";
                }
                if (num > 300 && num <= 600)
                {
                    result = "@%$";
                }
                if (num > 600 && num <= 999)
                {
                    result = "%$@";
                }
                break;
            case "5":
                num = Integer.parseInt(String.valueOf(System.currentTimeMillis() % 1000));
                if (num >= 0 && num <= 300)
                {
                    result = "!*^";
                }
                if (num > 300 && num <= 600)
                {
                    result = "^*!";
                }
                if (num > 600 && num <= 999)
                {
                    result = "*^!";
                }
                break;
            case "6":
                num = Integer.parseInt(String.valueOf(System.currentTimeMillis() % 1000));
                if (num >= 0 && num <= 300)
                {
                    result = "&*%";
                }
                if (num > 300 && num <= 600)
                {
                    result = "*%&";
                }
                if (num > 600 && num <= 999)
                {
                    result = "%*&";
                }
                break;
            case "7":
                num = Integer.parseInt(String.valueOf(System.currentTimeMillis() % 1000));
                if (num >= 0 && num <= 300)
                {
                    result = "?^$";
                }
                if (num > 300 && num <= 600)
                {
                    result = "$^?";
                }
                if (num > 600 && num <= 999)
                {
                    result = "?$^";
                }
                break;
            case "8":
                num = Integer.parseInt(String.valueOf(System.currentTimeMillis() % 1000));
                if (num >= 0 && num <= 300)
                {
                    result = "!?%";
                }
                if (num > 300 && num <= 600)
                {
                    result = "?!%";
                }
                if (num > 600 && num <= 999)
                {
                    result = "%?!";
                }
                break;
            case "9":
                num = Integer.parseInt(String.valueOf(System.currentTimeMillis() % 1000));
                if (num >= 0 && num <= 300)
                {
                    result = "*^@";
                }
                if (num > 300 && num <= 600)
                {
                    result = "^@*";
                }
                if (num > 600 && num <= 999)
                {
                    result = "@^*";
                }
                break;
            case "-":
                num = Integer.parseInt(String.valueOf(System.currentTimeMillis() % 1000));
                if (num >= 0 && num <= 300)
                {
                    result = "?#&";
                }
                if (num > 300 && num <= 600)
                {
                    result = "#?&";
                }
                if (num > 600 && num <= 999)
                {
                    result = "&?#";
                }
                break;
            case "/":
                num = Integer.parseInt(String.valueOf(System.currentTimeMillis() % 1000));
                if (num >= 0 && num <= 300)
                {
                    result = "?*@";
                }
                if (num > 300 && num <= 600)
                {
                    result = "*?@";
                }
                if (num > 600 && num <= 999)
                {
                    result = "?@*";
                }
                break;
            case "a":
                result = "@";
                break;
            case "b":
                result = "#";
                break;
            case "c":
                result = "$";
                break;
            case "z":
                result = "%";
                break;
            case ".":
                num = Integer.parseInt(String.valueOf(System.currentTimeMillis() % 1000));
                if (num >= 0 && num <= 300)
                {
                    result = "$@!";
                }
                if (num > 300 && num <= 600)
                {
                    result = "!$@";
                }
                if (num > 600 && num <= 999)
                {
                    result = "$!@";
                }
                break;
        }
        return result;
    }

}
